<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/client/backgroundManagement/commons/global.jsp" %>
<!DOCTYPE html>
<html>
<head>
<%@ include file="/client/backgroundManagement/commons/basejs.jsp" %>
<meta http-equiv="X-UA-Compatible" content="edge" />
 
	
<title>项目配置</title>
    <script type="text/javascript">
    var dataGrid;
    $(function() {
        dataGrid = $('#dataGrid').datagrid({
            url : '${path }' + '/projectTypeController/dataGrid',
            striped : true,
            rownumbers : true,
            pagination : true,
            singleSelect : true,
            idField : 'ID',
            sortName : 'ID',
            sortOrder : 'asc',
            pageSize : 20,
            pageList : [ 10, 20, 30, 40, 50, 100, 200, 300, 400, 500 ],
            frozenColumns : [ [  {
                title : 'ID',
                field : 'ID',
                width : 40,
                hidden : true
            }, {
                width : '160',
                title : '项目类型名称',
                field : 'PROJECT_TYPE_NAME',
                sortable : true
            } ,  {
                width : '650',
                title : '详细',
                field : 'DETAIL'
            } ,/* {
                width : '150',
                title : '创建时间',
                field : 'createTime',
                sortable : true 
            }, */{
                field : 'action',
                title : '操作',
                width : 200,
                formatter : function(value, row, index) {
                    var str = '';
                           // str += $.formatString('<a href="javascript:void(0)" class="role-easyui-linkbutton-ok" data-options="plain:true,iconCls:\'icon-ok\'" onclick="grantFun(\'{0}\');" >授权</a>', row.id);
                           // str += '&nbsp;&nbsp;|&nbsp;&nbsp;';
                            str += $.formatString('<a href="javascript:void(0)" class="role-easyui-linkbutton-edit" data-options="plain:true,iconCls:\'icon-edit\'" onclick="editFun(\'{0}\');" >编辑</a>', row.id);
                            str += '&nbsp;&nbsp;|&nbsp;&nbsp;';
                            str += $.formatString('<a href="javascript:void(0)" class="role-easyui-linkbutton-del" data-options="plain:true,iconCls:\'icon-del\'" onclick="deleteFun(\'{0}\');" >删除</a>', row.id);
                    return str;
                }
            } ] ],
            onLoadSuccess:function(data){
                $('.role-easyui-linkbutton-edit').linkbutton({text:'编辑',plain:true,iconCls:'icon-edit'});
                $('.role-easyui-linkbutton-del').linkbutton({text:'删除',plain:true,iconCls:'icon-del'});
            },
            toolbar : '#toolbar',
            pagination:false //是否显示分页
        });
    });
 
    
    function addFun() {
        parent.$.modalDialog({
            title : '添加',
            width : 800,
            height : 600,
            href : '${path }/views/admin/projectTypeAdd.jsp',
            buttons : [ {
                text : '确定',
                handler : function() {
                    parent.$.modalDialog.openner_dataGrid = dataGrid;//因为添加成功之后，需要刷新这个treeGrid，所以先预定义好
                    var f = parent.$.modalDialog.handler.find('#projectTypeAddForm');
                    f.submit();
                }
            } ]
        });
    }

    function editFun(id) {
    	 
        if (id == undefined || id == "undefined") {
            var rows = dataGrid.datagrid('getSelections');
            id = rows[0].ID;
        } else {
            dataGrid.datagrid('unselectAll').datagrid('uncheckAll');
        }
        parent.$.modalDialog({
            title : '编辑',
            width : 800,
            height : 600,
            href : '${path }/projectTypeController/editPage?id=' + id,
            buttons : [ {
                text : '确定',
                handler : function() {
                    parent.$.modalDialog.openner_dataGrid = dataGrid;//因为添加成功之后，需要刷新这个dataGrid，所以先预定义好
                    var f = parent.$.modalDialog.handler.find('#projectTypeEditForm');
                    f.submit();
                }
            } ]
        });
    }
 	
    
    function deleteFun(id) {
        if (id == undefined || id == "undefined") {//点击右键菜单才会触发这个
            var rows = dataGrid.datagrid('getSelections');
            id = rows[0].ID;
        } else {//点击操作里面的删除图标会触发这个
            dataGrid.datagrid('unselectAll').datagrid('uncheckAll');
        }
        parent.$.messager.confirm('询问', '您是否要删除当前项目类型？', function(b) {
            if (b) {
                progressLoad();
                $.post('${path }/projectTypeController/delete', {
                    id : id
                }, function(result) {
                    if (result.success) {
                    //    parent.$.messager.alert('提示', result.msg, 'info');
                        dataGrid.datagrid('reload');
                    }
                    progressClose();
                }, 'JSON');
            }
        });
    }

    function searchFun() {
        dataGrid.datagrid('load', $.serializeObject($('#searchForm')));
    }
    function cleanFun() {
        $('#searchForm input').val('');
        dataGrid.datagrid('load', {});
    }
    $("#searchParam").keydown(function(event) {    
    	debugger;
        if (event.keyCode == 13) {    
        	searchFun();
        }    
    })
    </script>
</head>
<body class="easyui-layout" data-options="fit:true,border:false">
    <div data-options="region:'north',border:true" style="height: 30px; overflow: hidden;background-color: #fff">
        <form id="searchForm">
            <table>
                <tr>
                    <th>名称:</th>
                    <td><input name="name" id="searchParam" placeholder="请输入项目名称"/></td>
                    
                    <td>
<!-- 
<th>创建时间:</th>
                    <input name="createdateStart" placeholder="点击选择时间" onclick="WdatePicker({readOnly:true,dateFmt:'yyyy-MM-dd HH:mm:ss'})" readonly="readonly" />至<input  name="createdateEnd" placeholder="点击选择时间" onclick="WdatePicker({readOnly:true,dateFmt:'yyyy-MM-dd HH:mm:ss'})" readonly="readonly" />


 -->
                    <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="searchFun();">查询</a><a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-cancel',plain:true" onclick="cleanFun();">清空</a>
                    </td>
                </tr>
            </table>
        </form>
 
    </div>
            <div id="toolbar" >
            <a onclick="addFun();" href="javascript:void(0);" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-add'">添加</a>
    </div>
    <div data-options="region:'center',border:false">
        <table id="dataGrid" data-options="fit:true,border:false" pagination="false"></table>
    </div>

</body>
</html>